<template>
  <div class="ligin-user">
    <div class="ligin-user-right">
      <h1>欢迎登陆</h1>

      <span class="span">全国自然灾害分布展示系统</span>

      <br />
      <br />
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="70px"
        class="demo-ruleForm"
      >
        <el-form-item label="用户名" prop="username">
          <el-input v-model="ruleForm.username"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="ruleForm.password" show-password></el-input>
        </el-form-item>
      </el-form>
      <br />

      <div class="submit">
        <el-button
          @click="submitForm('ruleForm')"
          type="primary"
          round
          style="width: 60%; color: white; margin: 0 auto"
          >登陆</el-button
        >
      </div>
      <br />
      <br />
    </div>
    <div class="ligin-user-left">
      <h1 class="title">自然灾害分布展示系统</h1>
      <img style="width: 80%" src="../assets/map.d3a33a4d.png" alt="" />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userList: [],

      ruleForm: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },

  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          //   console.log(this.ruleForm);
          if (
            this.ruleForm.username === "admin" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功!",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user1" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功!",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user2" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user3" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user4" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user5" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user6" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user7" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else if (
            this.ruleForm.username === "user8" &&
            this.ruleForm.password === "123456"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$message({
              message: "登陆成功！",
              type: "success",
            });
            this.$router.push("/heritage/industry");
          } else {
            this.$message.error("用户名或密码错误");
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style>
.ligin-user {
  height: 100vh;
  background-image: url("../../src/assets/bg.4ce0e881.png");
  background-size: cover;
  /* background-position-y: 60%; */
}
.ligin-user-right {
  position: absolute;
  top: 25%;
  right: 50px;
  width: 530px;
  padding: 0 30px;
  background-color: rgba(255, 255, 255);
}
.ligin-user-right h1 {
  margin-bottom: 0;
  font-family: 黑体;
}
.ligin-user-right .span {
  margin: 0;
  color: #9b9b9b;
}
.ligin-user-right .span a {
  color: #2e58ff;
  text-decoration: none;
}
.submit {
  text-align: center;
}
.title {
  color: white;
  font-family: 楷体;
}
.ligin-user-left {
  position: absolute;
  left: 100px;
  top: 25%;
  margin-top: -50px;
}
.ligin-user-left h1 {
  font-size: 40px;
  margin: 0;
  padding-left: 80px;
  padding-bottom: 50px;
}
.ligin-user-left p {
  font-size: 30px;
  margin: 0;
  font-weight: 300;
}
</style>
